package cn.com.quickpay;

import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

import cn.com.quickpay.core.common.Configure;
import cn.com.quickpay.core.service.quick.QuickPay;
import cn.com.quickpay.core.service.quick.QuickPayQuery;

public class Example {
	
	public static void main(String[] args){
//		quickPayExample();
		quickPayQueryExample();
	}

	/**
	 * 快捷支付
	 */
    public static void quickPayExample(){
    	try {
    		HashMap<String, String> params = new HashMap<String, String>();
    	    params.put("out_trade_no", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
    	    params.put("order_time", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
    	    params.put("total_fee", "100");
    	    params.put("body", "快捷测试");
    	    params.put("notify_url", "http://t.yunpuvip.com/pay/sand/notify.shtml");
    	    params.put("time_expire", "30");
    	    params.put("client_ip", InetAddress.getLocalHost().getHostAddress());
    	    params.put("return_url", "");
    	    params.put("attach", "");
    	    params.put("device_info", "");
    	    String result =  new QuickPay().exec(params);
    	    System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
    
    /**
     * 快捷支付查询
     */
    public static void quickPayQueryExample(){
    	try {
    		HashMap<String, String> params = new HashMap<String, String>();  
    		params.put("out_trade_no", "20170825180523");
    	    String result =  new QuickPayQuery().exec(params);
    	    System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
    }

}
